# Contributor: Jason Qiu <jasonwqiu@gmail.com>

_realname=streamlink
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=7.3.0
pkgrel=1
pkgdesc="A CLI utility that extracts streams from various services and pipes them into a video player of choice. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: streamlink'
  'purl: pkg:pypi/streamlink'
)
msys2_repository_url='https://github.com/streamlink/streamlink/'
url='https://streamlink.github.io/'
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python-"{certifi,isodate,lxml,pycountry,pycryptodome,pysocks,requests,trio,trio-websocket,urllib3,websocket-client})
makedepends=("${MINGW_PACKAGE_PREFIX}-python-"{build,installer,setuptools})
optdepends=("${MINGW_PACKAGE_PREFIX}-ffmpeg: Required to play streams that are made up of separate audio and video streams, eg. YouTube 1080p+")
options=('!strip')
source=("https://github.com/${_realname}/${_realname}/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz"{,.asc})
sha256sums=('1e20d624451f26156a38b9dae5bdfcc6640a8bdf27922370edec8abe237abb08'
            'SKIP')
validpgpkeys=('CDAC41B9122470FAF357A9D344448A298D5C3618') # Streamlink signing key <streamlink@protonmail.com>

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}"${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
